fix(backend/frontend): gzip middleware + StreamDetailDrawer Stellar Expert tx links#619
Conversation
…Expert tx links fix(ritik4ever#364): gzip compression via compression({ threshold: 1024 }) is already applied as early middleware in backend/src/index.ts — confirmed present and correctly registered before all route handlers fix(ritik4ever#399): render all txHash values in StreamDetailDrawer event history as clickable links to https://stellar.expert/explorer/testnet/tx/<hash> - add TxHashLink component: truncates to first 8 + last 8 chars, full hash in title tooltip, opens in new tab with rel=noopener noreferrer - add txHash field to StreamEvent interface in services/api.ts - wire TxHashLink into event history list items - add txHash to MSW mock handler for testing - 5 new Vitest tests: correct href, target=_blank, rel, truncation, no link when txHash absent — all 34 drawer tests pass
|
@ogazboiz is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@ogazboiz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughWalkthroughAdds a TxHashLink: Stellar Expert transaction links
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/components/StreamDetailDrawer.test.tsx`:
- Around line 454-460: The test in StreamDetailDrawer is too broad because it
only checks the total number of “View transaction” links, so it won’t catch a
link appearing on the “Stream created” row. Update the assertion in the test
case for StreamDetailDrawer to scope directly to the “Stream created” list
item/row and verify that specific row has no transaction link, while still
allowing the claimed event to have one. Use the existing StreamDetailDrawer
render and the “Stream created” text to locate the correct row.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b178ee75-37ca-4a24-b2de-512265e072cf
📒 Files selected for processing (4)
frontend/src/components/StreamDetailDrawer.test.tsxfrontend/src/components/StreamDetailDrawer.tsxfrontend/src/handlers.tsfrontend/src/services/api.ts
| it('does not render a tx link when txHash is absent', async () => { | ||
| render(<StreamDetailDrawer streamId="42" onClose={onClose} />); | ||
| await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument()); | ||
| // "created" event has no txHash — only the "claimed" event has a link | ||
| const links = screen.queryAllByRole('link', { name: /View transaction/i }); | ||
| expect(links.length).toBeLessThanOrEqual(1); | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert against the specific "Stream created" event row.
Line 458 only caps the total number of tx links on the page, so this still passes if the link moves from the claimed event to the created event. Scope the assertion to the "Stream created" list item and verify that row has no transaction link.
Suggested test shape
it('does not render a tx link when txHash is absent', async () => {
render(<StreamDetailDrawer streamId="42" onClose={onClose} />);
await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument());
- // "created" event has no txHash — only the "claimed" event has a link
- const links = screen.queryAllByRole('link', { name: /View transaction/i });
- expect(links.length).toBeLessThanOrEqual(1);
+ const createdRow = screen.getByText('Stream created').closest('li');
+ expect(createdRow).not.toBeNull();
+ expect(
+ within(createdRow as HTMLElement).queryByRole('link', { name: /View transaction/i }),
+ ).not.toBeInTheDocument();
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('does not render a tx link when txHash is absent', async () => { | |
| render(<StreamDetailDrawer streamId="42" onClose={onClose} />); | |
| await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument()); | |
| // "created" event has no txHash — only the "claimed" event has a link | |
| const links = screen.queryAllByRole('link', { name: /View transaction/i }); | |
| expect(links.length).toBeLessThanOrEqual(1); | |
| }); | |
| it('does not render a tx link when txHash is absent', async () => { | |
| render(<StreamDetailDrawer streamId="42" onClose={onClose} />); | |
| await waitFor(() => expect(screen.getByText('Stream created')).toBeInTheDocument()); | |
| const createdRow = screen.getByText('Stream created').closest('li'); | |
| expect(createdRow).not.toBeNull(); | |
| expect( | |
| within(createdRow as HTMLElement).queryByRole('link', { name: /View transaction/i }), | |
| ).not.toBeInTheDocument(); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/components/StreamDetailDrawer.test.tsx` around lines 454 - 460,
The test in StreamDetailDrawer is too broad because it only checks the total
number of “View transaction” links, so it won’t catch a link appearing on the
“Stream created” row. Update the assertion in the test case for
StreamDetailDrawer to scope directly to the “Stream created” list item/row and
verify that specific row has no transaction link, while still allowing the
claimed event to have one. Use the existing StreamDetailDrawer render and the
“Stream created” text to locate the correct row.
Closes #364
Closes #399
Closes #359
Closes #352
Summary
#364 — Gzip compression middleware
compression({ threshold: 1024 })is already registered as early middleware inbackend/src/index.ts(before all route handlers), compressing all responses above 1 KB. No further changes needed — this issue is resolved.#399 — StreamDetailDrawer Stellar Expert transaction links
TxHashLinkcomponent toStreamDetailDrawer.tsx: renders anytxHashas a clickable<a>tohttps://stellar.expert/explorer/testnet/tx/<hash>, opens in a new tab withrel="noopener noreferrer", truncates display to first 8 + last 8 chars, full hash intitletooltiptxHash?: stringfield toStreamEventinterface inservices/api.tsTxHashLinkinto the event history list — renders only whentxHashis presenttxHashon theclaimedevent for test coveragetarget=_blank,rel, truncated display, absent when no hash — all 34 drawer tests passSummary by CodeRabbit
New Features
Bug Fixes